package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author Justin Parker
 * @Date 2024/8/3 0003 9:22
 * @Version 1.0
 */
/***
 * 1.实例化
 * 2.属性赋值
 * 3.初始化
 * 4.使用
 * 5.销毁
 * */
@Component
public class Life {

    private String meaning;

    public Life() {
        System.out.println("1.无参构造实例化");
    }
    @Value("生命的意义在于静止")
    public void setMeaning(String meaning) {
        this.meaning = meaning;
        System.out.println("2.set方法属性赋值");
    }

    @PostConstruct  //生命周期初始化方法
    public void init(){
        System.out.println("3.生命周期初始化方法");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("5.生命周期销毁方法");
    }
}
